export default {
  namespaced: true,
  state: {
    role: localStorage.getItem('role') || '',
    token: localStorage.getItem('token') || '',
    userInfo: localStorage.getItem('userInfo')
      ? JSON.parse(localStorage.getItem('userInfo'))
      : {}
  },
  mutations: {
    INIT_USER_INFO (state, { role, token, userInfo }) {
      state.role = role
      state.token = token
      state.userInfo = userInfo
    },
    USER_LOGOUT () {
      // 清除缓存
      localStorage.removeItem('role')
      localStorage.removeItem('token')
      localStorage.removeItem('userInfo')
    }
  }
}
